﻿Imports Utilerias

Public Class EnviosDeCorreoBL
    Public Sub enviaMailCreacionCuenta(ByVal pRFCEmi As String, ByVal pRazSocEmi As String, ByVal pUsuario As String,
                                       ByVal pContraseña As String, ByVal pCorreoEmi As String)
        Dim servCorreo As servEnviaCorreo.ServiceMailClient = New servEnviaCorreo.ServiceMailClient()
        Dim strMsgs() As String = {}
        Dim strBody As String = ""
        Try
            strBody = Archivos.ReadHtmlFile(System.IO.Path.Combine(My.Settings.PathFiles, "PlantillasCorreo\PlantillaNuevaCuenta.html")).ToString()
            strBody = strBody.Replace("[RAZONSOCIAL]", pRazSocEmi)
            strBody = strBody.Replace("[RFC]", pRFCEmi)
            strBody = strBody.Replace("[USER]", pUsuario)
            strBody = strBody.Replace("[PWD]", pContraseña)
            servCorreo.EnviarMail("Notificación de Registro",
                                  New String() {pCorreoEmi}, Nothing, strBody, True, Nothing, True, strMsgs)
            If (strMsgs.Count > 0) Then
                'TODO: Enviar a bitacoras
            End If
        Catch ex As Exception
            Log.LogException(ex, "EnviosDeCorreoBL.enviaMailCreacionCuenta")
            Throw
        Finally
            servCorreo = Nothing
            strMsgs = Nothing
            strBody = Nothing
        End Try
    End Sub

    Public Sub enviaMailCambioContraseña(ByVal pRFCEmi As String, ByVal pUsuario As String, ByVal pContraseña As String, ByVal pCorreoUsuario As String)
        Dim servCorreo As servEnviaCorreo.ServiceMailClient = New servEnviaCorreo.ServiceMailClient()
        Dim strMsgs() As String = {}
        Dim strBody As String = ""
        Try
            strBody = Archivos.ReadHtmlFile(System.IO.Path.Combine(My.Settings.PathFiles, "PlantillasCorreo\PlantillaDatosAcceso.html")).ToString()
            strBody = strBody.Replace("[RFC]", pRFCEmi)
            strBody = strBody.Replace("[USER]", pUsuario)
            strBody = strBody.Replace("[PWD]", pContraseña)
            servCorreo.EnviarMail("Notificación de Nueva Contraseña",
                                  New String() {pCorreoUsuario}, Nothing, strBody, True, Nothing, True, strMsgs)
            If (strMsgs.Count > 0) Then
                'TODO: Enviar a bitacoras
            End If
        Catch ex As Exception
            Log.LogException(ex, "EnviosDeCorreoBL.enviaMailCambioOntraseña")
            Throw
        Finally
            servCorreo = Nothing
            strMsgs = Nothing
            strBody = Nothing
        End Try
    End Sub
End Class
